package server.startup;

import server.Context;
import server.Lifecycle;
import server.Loader;
import server.Wrapper;
import server.connector.http.HttpConnector;
import server.core.SimpleLoader;
import server.core.StandardContext;
import server.core.StandardWrapper;

public class BootStrap {
    public static void main(String[] args) {
        HttpConnector connector = new HttpConnector();
        Wrapper wrapper = new StandardWrapper();
        wrapper.setName("M");
        wrapper.setServletClass("WrapperTestServlet");
        wrapper.addInitParameter("p1", "v1");
        wrapper.addInitParameter("p2", "v2");

        StandardContext context = new StandardContext();
        wrapper.setParent(context);
        Loader loader = new SimpleLoader();
        context.setLoader(loader);
        context.initial();
        connector.setContainer(wrapper);
        try {
            connector.initialize();
            connector.start();
            ((Lifecycle)wrapper).start();
            System.in.read();
            ((Lifecycle)wrapper).stop();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
